package com.sky.config;


import com.sky.properties.AliOssProperties;
import com.sky.utils.AliOssUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableConfigurationProperties(AliOssProperties.class)
public class AliOSSAutoConfig {

    /**
     * 因为AliOssUtil上没有@Component注解
     * 定义配置类拿到AliOssUtil工具类的对象
     */
    @Autowired
    private AliOssProperties aliOssProperties;
    @Bean
    public AliOssUtil getAliOssUtil(){
        return new AliOssUtil(aliOssProperties.getEndpoint(), aliOssProperties.getAccessKeyId(),
                aliOssProperties.getAccessKeySecret(), aliOssProperties.getBucketName());
    }
}
